﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for Entities
/// </summary>
public class Entities
{
    #region DateTime
    public string ConvertDateTime(string datetime)
    {
        return System.DateTime.Parse(datetime).ToString("'Ngày' dd 'tháng' MM 'năm' yyyy '('HH 'giờ' mm 'phút' ss 'giây)'");
    }
    public string ConvertShortDateTime(string datetime)
    {
        return System.DateTime.Parse(datetime).ToString("dd '/' MM '/' yyyy ', 'HH ':' mm ' GMT+7 '");
    }
    public string FormatDateTimeVN(string datetime)
    {
        return System.DateTime.Parse(datetime).ToString("dd '/' MM '/' yyyy");
    }
    public string FormatDateTimeEN(string datetime)
    {
        return System.DateTime.Parse(datetime).ToString("MM '/' dd '/' yyyy");
    }
    public string ShotFormatDateTimeVN(string datetime)
    {
        return System.DateTime.Parse(datetime).ToString("dd'/'MM'/'yyyy");
    }
    public string HouseFormatDateTimeVN(string datetime)
    {
        return System.DateTime.Parse(datetime).ToString("HH':'mm");
    }
    public string FullTime()
    {
        string myFullTime = string.Empty;
        myFullTime = System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + System.DateTime.Now.Hour.ToString() + System.DateTime.Now.Minute.ToString() + System.DateTime.Now.Millisecond.ToString();
        return myFullTime;
    }
    public string CutDateTimeVN(System.DateTime datetime)
    {
        string strCurDT = FormatDateTimeVN(System.DateTime.Now.ToString());
        string mydt = datetime.DayOfWeek.ToString().Substring(0, 3);
        string Output = "";
        switch (mydt)
        {
            case "Mon":
                Output = "Thứ hai, " + strCurDT;
                break;
            case "Tue":
                Output = "Thứ ba, " + strCurDT;
                break;
            case "Wed":
                Output = "Thứ tư, " + strCurDT;
                break;
            case "Thu":
                Output = "Thứ năm, " + strCurDT;
                break;
            case "Fri":
                Output = "Thứ sáu, " + strCurDT;
                break;
            case "Sat":
                Output = "Thứ bảy, " + strCurDT;
                break;
            case "Sun":
                Output = "Chủ nhật, " + strCurDT;
                break;

        }
        return Output;
    }
    public string FullDateTimeVN(System.DateTime datetime)
    {
        string strCurDT = ConvertShortDateTime(System.DateTime.Now.ToString());
        string mydt = datetime.DayOfWeek.ToString().Substring(0, 3);
        string Output = "";
        switch (mydt)
        {
            case "Mon":
                Output = "Thứ hai, " + strCurDT;
                break;
            case "Tue":
                Output = "Thứ ba, " + strCurDT;
                break;
            case "Wed":
                Output = "Thứ tư, " + strCurDT;
                break;
            case "Thu":
                Output = "Thứ năm, " + strCurDT;
                break;
            case "Fri":
                Output = "Thứ sáu, " + strCurDT;
                break;
            case "Sat":
                Output = "Thứ bảy, " + strCurDT;
                break;
            case "Sun":
                Output = "Chủ nhật, " + strCurDT;
                break;

        }
        return Output;
    }
    public string CutDateTimeEN(System.DateTime datetime)
    {
        string strCurDT = FormatDateTimeEN(System.DateTime.Now.ToString());
        string mydt = datetime.DayOfWeek.ToString().Substring(0, 3);
        string Output = "";
        switch (mydt)
        {
            case "Mon":
                Output = "Monday, " + strCurDT;
                break;
            case "Tue":
                Output = "Tuesday, " + strCurDT;
                break;
            case "Wed":
                Output = "Wednesday, " + strCurDT;
                break;
            case "Thu":
                Output = "Thursday, " + strCurDT;
                break;
            case "Fri":
                Output = "Friday, " + strCurDT;
                break;
            case "Sat":
                Output = "Saturday, " + strCurDT;
                break;
            case "Sun":
                Output = "Sunday, " + strCurDT;
                break;

        }
        return Output;
    }
    public string FullDateTimeEN(System.DateTime datetime)
    {
        string strCurDT = System.DateTime.Now.ToString();
        string mydt = datetime.DayOfWeek.ToString().Substring(0, 3);
        string Output = "";
        switch (mydt)
        {
            case "Mon":
                Output = "Monday, " + strCurDT;
                break;
            case "Tue":
                Output = "Tuesday, " + strCurDT;
                break;
            case "Wed":
                Output = "Wednesday, " + strCurDT;
                break;
            case "Thu":
                Output = "Thursday, " + strCurDT;
                break;
            case "Fri":
                Output = "Friday, " + strCurDT;
                break;
            case "Sat":
                Output = "Saturday, " + strCurDT;
                break;
            case "Sun":
                Output = "Sunday, " + strCurDT;
                break;

        }
        return Output;
    }
    public string GetDay(string datetime)
    {
        return System.DateTime.Parse(datetime).ToString("dd");
    }
    public string GetMonth(string datetime)
    {
        return System.DateTime.Parse(datetime).ToString("MM");
    }
    public string GetYear(string datetime)
    {
        return System.DateTime.Parse(datetime).ToString("yyyy");
    }
    #endregion DateTime
    public string EncodePassword(string strPassword, string strFormat)
    {
        if (strFormat == "") { strFormat = "MD5"; }
        return FormsAuthentication.HashPasswordForStoringInConfigFile(strPassword, strFormat);
    }
    #region fomat String
    public string fomat(string Str)
    {
        string sti = string.Empty;
        if (Str.Length == 8)
        {
            string st2 = Str.Substring(0, 2);
            string st1 = Str.Substring(2, 3);
            string st3 = Str.Substring(5, 3);
             sti = st2 + "." + st1 + "." + st3;
           
        }
        if (Str.Length == 7)
        {
            string st2 = Str.Substring(0, 1);
            string st1 = Str.Substring(1, 3);
            string st3 = Str.Substring(4, 3);
            sti = st2 + "." + st1 + "." + st3;
            
        }
        if (Str.Length == 6)
        {
            string st2 = Str.Substring(0, 3);
            string st1 = Str.Substring(4, 3);
             sti = st2 + "." + st1;
            
        }
        if (Str.Length == 5)
        {
            string st2 = Str.Substring(0, 2);
            string st1 = Str.Substring(2, 3);
             sti = st2 + "." + st1;
            
        }
        return sti;
    }
    #endregion fomat String
    #region Gfomat String
    public string getfomat(string Str)
    {
        string sti = string.Empty;
        if (Str.Length == 10)
        {
            string st2 = Str.Substring(0, 2);
            string st1 = Str.Substring(3, 3);
            string st3 = Str.Substring(6, 3);
             sti = st2 + "." + st1 + "." + st3;
           
        }
        if (Str.Length == 9)
        {
            string st2 = Str.Substring(0, 1);
            string st1 = Str.Substring(2, 3);
            string st3 = Str.Substring(6, 3);
            sti = st2 + "." + st1 + "." + st3;
            
        }
        if (Str.Length == 7)
        {
            string st2 = Str.Substring(0, 3);
            string st1 = Str.Substring(4, 3);
             sti = st2 + "." + st1;
            
        }
        if (Str.Length == 6)
        {
            string st2 = Str.Substring(0, 2);
            string st1 = Str.Substring(3, 3);
             sti = st2 + "." + st1;
            
        }
        return sti;
    }
    #endregion Gfomat String
}
